package com.ruishun.controller.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;


/**
 * <p>Title: LoginHandlerInterceptor</p>
 * <p>Description: 登录拦截操作</p>
 * <p>Company: ruishun</p>
 * @author weil
 * @date 2018年1月3日
 */
public class LoginHandlerInterceptor implements HandlerInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception {
//		ErpUser user = (ErpUser) request.getSession().getAttribute("user");
//		if(user == null) {
//			String uri = request.getRequestURI();
//			if(uri.endsWith("login")||uri.endsWith("check")) {
//				//进行登录操作就放行
//				return true;
//			}else {
//				//未登录，不在登录界面，直接拦截使其去登录
//				request.getRequestDispatcher("login").forward(request, response);
//				return false;
//			}
//		}
		return true;
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object, Exception exception)
			throws Exception {

	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView modelAndView)
			throws Exception {

	}


}
